install nodejs:
  cmd.run:
    - name: |
        curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
        yum -y install nodejs
        yum install gcc-c++ make
        yum install nodejs npm --enablerepo=epel
        npm install forever -g
    - unless: node -v

#http://192.168.11.11:8888/
run example:
  file.managed:
    - name: /workspaces/nodejs/HelloNodejs/server.js
    - source: salt://nodejs/files/server.js
    - makedirs: True
  cmd.run:
    - name: |
        cd /workspaces/nodejs/HelloNodejs
        {% if salt['status.pid']('forever.* server.js') != '' %}
        forever stop server.js
        {% endif %}
        forever start -a -l forever.log -o out.log -e err.log server.js